<?php
class erpapi_router_mapping {

    private static $_rsp_method_mapping = array(
        'ome.remark.add'                 => 'shop.remark.add',
        'ome.logistics.push'             => 'hqepay.logistics.push',
        'ome.payment.add'                => 'shop.payment.add',
        'ome.payment.status_update'      => 'shop.payment.statusUpdate',
        'ome.aftersale.add'              => 'shop.aftersale.add',
        'ome.aftersale.status_update'    => 'shop.aftersale.statusUpdate',
        'ome.aftersale.logistics_update' => 'shop.aftersale.logisticsUpdate',
        'ome.refund.add'                 => 'shop.refund.add',
        'ome.refund.aftersale_add'       => 'shop.refund.aftersale_add',
        'ome.refund.status_update'       => 'shop.refund.statusUpdate',
        'ome.order.payment_update'       => 'shop.order.payment_update',
        'ome.order.memo_update'          => 'shop.order.memo_update',
        'ome.order.memo_add'             => 'shop.order.memo_add',
        'ome.order.custom_mark_update'   => 'shop.order.custom_mark_update',
        'ome.order.custom_mark_add'      => 'shop.order.custom_mark_add',
        'ome.order.ship_status_update'   => 'shop.order.ship_status_update',
        'ome.order.pay_status_update'    => 'shop.order.pay_status_update',
        'ome.order.status_update'        => 'shop.order.status_update',
        'ome.order.add'                  => 'shop.order.add',
        'ome.aftersalev2.add'            => 'shop.aftersalev2.add',
        'ome.unionpay.push'             => 'unionpay.logistics.push',
    );

    public static $_rsp_nodetype_mapping = array(
        'weimeng','zhe800','youzan','yintai','yihaodian','wx','wdwd','vop','vjia','ecos.b2c','ecos.dzg','shopex_b2c','bbc','ecshop_b2c','public_b2c','shopex_b2b','suning','qqbuy','paipai','mogujie','mia','mengdian','meilishuo','juanpi','icbc','gome','feiniu','dangdang','ccb','beibei','amazon','alibaba','360buy'
    );

    public static $_afterSaleV2 = array(
        'meilishuo','beibei','feiniu','yihaodian','zhe800'
    );

    #是否映射到erpapi中response
    public static function rspServiceMapping($service,$method,$node_id){
        if (self::$_rsp_method_mapping[$method]) return self::$_rsp_method_mapping[$method];

        // if ($method == 'ome.order.add' && in_array(self::get_node_type($node_id), self::$_rsp_nodetype_mapping)) return 'ome.order.add';
        //if ($method == 'ome.aftersalev2.add' && in_array(self::get_node_type($node_id), self::$_afterSaleV2)) return 'shop.aftersalev2.add';

        return false;
    }

    private static function get_node_type($node_id)
    {
        $row = kernel::database()->selectrow('SELECT node_type FROM sdb_ome_shop WHERE node_id="'.addslashes($node_id).'"');

        return $row['node_type'];
    }
}